new Vue({
	el: "#app", 
	data: {
		searchVal: "",
		imgUrl: "https://app.meijiangzi.com/static/",
		bannerImg: [],
		ImgBaseUrl: "https://app.meijiangzi.com/static/",
		project_list: "",
		showBtn: !1,
		btnText: "展开全部",
		pageNum: 1,
		mallList: [],
		bgImg: !1, 
		str: "",
		isbottom: !1,
		longitude: "",
		latitude: "",
		province: 13,
		alpha: 0,
		activityList: "",
		scrollTop: 0,
		translate:0,
		picWidth:750, 
		isExcute: false 
	},
	methods: {
	    search_focus: function() {
	        Jump.to(page.index.search);
	    },
	    searchEvent: function() {
	        wx.navigateTo({
	            url: "/pages/searchPage/main?type=1"
	        });
	    },
	    to_detail: function(t) {
	        switch (t.type - 0) {
	          case 1:
	            Jump.to(page.index.list, "typeId=" + t.typeId + "&name=" + t.name);
	            break;
	
	          case 2:
	            wx.navigateTo({
	                url: "/pages/goods_detail/main?goods_id=" + JSON.parse(t.json_data).id
	            });
	            break;
	
	          case 3:
	            wx.showToast({
	                title: "敬请期待",
	                icon: "none",
	                duration: 2e3,
	                mask: !1
	            });
	            break;
	
	          case 4:
	            wx.navigateTo({
	                url: "/pages/sign_in/main"
	            });
	            break;
	
	          case 5:
	            wx.navigateTo({
	                url: "/pages/shop_type_detail/main?id=" + JSON.parse(t.json_data).id
	            });
	            break;
	
	          case 6:
	            Jump.to(page.index.detail, "id=" + t.businessId);
	            break;
	
	          case 7:
	            wx.navigateTo({
	                url: "/pages/categorize_list/main?url=" + JSON.parse(t.json_data).id
	            });
	        }
	    },
	    getSwiper: function() {
	        var t = this;
	        wx.showLoading({
	            title: "加载中",
	            mask: !0
	        }), this.$http.post(baseUrl+"/banner/query", {
	            type: "pzym"
	        }).then(function(a) {
	            wx.hideLoading();
	            var s = a.data;
	          if (!s.success) return wx.hideLoading(), wx.showToast({
	            title: s.description,
	                icon: "none",
	                duration: 2e3,
	                mask: !0
	            }), !1;
	            t.bannerImg = s.data;
				  t.bannerImg.forEach(function (e) {
					e.type = 6;
				  });
				  this.bannersRock(true);
	        }).catch(function(t) {
	            wx.hideLoading(), wx.showToast({
	                title: "网络错误，请检查网络",
	                icon: "none",
	                duration: 2e3,
	                mask: !0
	            });
	        });
	    },
	    getListData: function() {
	        var t = this;
	        wx.showLoading({
	            title: "加载中",
	            mask: !0
	        }), this.$http.post(baseUrl+"api/project/allProjectNav").then(function(a) {
	            wx.hideLoading();
	            var s = a.data;
	            if (!s.success) return wx.hideLoading(), wx.showToast({
	                title: s.description,
	                icon: "none",
	                duration: 2e3,
	                mask: !0
	            }), !1;
	            t.project_list = s.data;
				t.project_list.forEach(function (e) {
					e.type = 1;
				  });
	        }).catch(function(t) {
	            wx.hideLoading(), wx.showToast({
	                title: "网络错误，请检查网络",
	                icon: "none",
	                duration: 2e3,
	                mask: !0
	            });
	        });
	    },
	    clickShow: function(t) {
	        this.showBtn = !this.showBtn, 1 == this.showBtn ? this.btnText = "收起全部" : this.btnText = "展开全部";
	    },
	    getData: function(t) {
	        var a = this;
	        if (this.isbottom) return !1;
	        wx.showLoading({
	            title: "加载中",
	            mask: !0
	        });
	        var s = {
	          currentPage: this.pageNum,
	          pageSize: 10,
	            lat: this.latitude,
	            lng: this.longitude
	          // ,zoneCode: this.province
	        };
	      this.hot ? s.orderType = 1 : this.star ? s.orderType = 2 : this.price && (s.price_sort = this.price) + 2;
	        setTimeout(function() {
	          a.$http.post(baseUrl+"api/project/list", s).then(function(t) {
	                wx.hideLoading();
	                var s = t.data;
	                if (!s.success) return wx.hideLoading(), wx.showToast({
	                    title: s.description,
	                    icon: "none",
	                    duration: 2e3,
	                    mask: !0
	                }), !1;
					this.isExcute = false; 
	                if (s.data.length > 0 && 1 == a.pageNum) a.mallList = s.data; else if (s.data.length > 0 && a.pageNum > 1) {
	                    var i;
	                    (i = a.mallList).push.apply(i, s.data);
	                } else if (0 == s.data.length && a.pageNum > 1) return wx.showToast({
	                    title: "已经到最底下了",
	                    icon: "none",
	                    duration: 1e3,
	                    mask: !0
	                }), a.isbottom = !0, !1;
	            }).catch(function(t) {
	                wx.hideLoading(), wx.showToast({
	                    title: "网络错误，请检查网络",
	                    icon: "none",
	                    duration: 2e3,
	                    mask: !0
	                });
	            });
	        }, 200);
	    },
	    toMalldetail: function(t) {
	        Jump.to(page.index.detail, "id=" + t.guid);
	    },
	    toCategorize_list: function(t, a) {
	        wx.navigateTo({
	            url: "/pages/categorize_list/main?url=" + t + "&project_name=" + a
	        });
	    },
	    pullrefresh: function() {
	        this.pageNum++, this.getData();
	    },
	    get_location: function() {
	        var t = this;
	        t.longitude = wx.getStorageSync("userLng"), t.latitude = wx.getStorageSync("userLat"), t.getData();
	    },
	    scroll: function() {
			var s = srollEvent.getScrollTop();
			console.log(s);
	        this.scrollTop = s, this.alpha = this.scrollTop / 200 > 1 ? 1 : this.scrollTop / 200;
	    },
	    activityEvent: function(t) {
	        switch (t.type - 0) {
	          case 1:
	            wx.navigateTo({
	                url: "/pages/advertisement/main?url=" + t.links
	            });
	            break;
	
	          case 2:
	            wx.navigateTo({
	                url: "/pages/goods_detail/main?goods_id=" + JSON.parse(t.json_data).id
	            });
	            break;
	
	          case 3:
	            wx.showToast({
	                title: "敬请期待",
	                icon: "none",
	                duration: 2e3,
	                mask: !1
	            });
	            break;
	
	          case 4:
	            wx.navigateTo({
	                url: "/pages/sign_in/main"
	            });
	            break;
	
	          case 5:
	            wx.navigateTo({
	                url: "/pages/categorize_list/main?id=" + JSON.parse(t.json_data).id
	            });
	            break;
	
	          case 6:
	            wx.navigateTo({
	                url: "/pages/project_detail/main?id=" + JSON.parse(t.json_data).id
	            });
	            break;
	
	          case 7:
	            wx.navigateTo({
	                url: "/pages/categorize_list/main?url=" + JSON.parse(t.json_data).id
	            });
	        }
	    },
		handleScroll: function(){
			// 防止重复
			if (this.isExcute) {
				return;
			}
			if (this.isbottom) {
				return;
			}
			var flag = srollEvent.isReachBottom();
			if (!flag) {
				return;
			}
			this.isExcute = true;
			this.scroll();
			this.pullrefresh();
		},
		bannersRock:function(init){
			var t = this;
			if(init){
				t.left = new Array();
				var banners = this.bannerImg;
				banners.forEach(function(e,index){
					if(index==banners.length-1){
						return;
					}
					t.left.push((index+1)*t.picWidth*-1);
				});
				t.right = new Array();
				t.flag = true;
				
			}
			t.inter = setInterval(function(){
				if(t.flag){
					t.translate = t.left.shift();
					t.right.push(t.translate);
					if(t.left.length==0){
						t.flag =false;
					}
				}else{
					var translate = t.right.pop();
					t.translate = translate+t.picWidth;
					t.left.push(translate);
					if(t.right.length==0){
						t.flag = true;
						t.left.reverse();
					}
				}
			},2000)
			
		},
		touchStart: function(ev) {
			ev = ev || event;
			ev.preventDefault();
			//                      console.log(ev.targetTouches);
			//                      console.log(ev.changedTouches);
			if (ev.touches.length == 1) { //tounches类数组，等于1时表示此时有只有一只手指在触摸屏幕
				this.startX = ev.touches[0].clientX; // 记录开始位置
			}
		},
		touchEnd: function(ev, e,index) {
			ev = ev || event;
			ev.preventDefault();
			if (ev.changedTouches.length == 1) {
				var endX = ev.changedTouches[0].clientX;
				this.disX = endX - this.startX;
				if (this.disX < 0) {
					// 左滑
					if(index==this.bannerImg.length-1){
						return;
					}else{
						clearInterval(this.inter)
						this.translate = this.translate-this.picWidth;
						this.bannersRock(false);
					}
				} else if(this.disX >0) {
					// 右滑
					if(index==0){
						return;
					}else{
						clearInterval(this.inter)
						this.translate = this.translate+this.picWidth;
						this.bannersRock(false);
					}
				}else{
					this.to_detail(e);
				}
			}
		},
	},
	created: function(t) {
		var t = this; 
		this.picWidth = window.screen.width*2;
		this.getSwiper(), this.getListData();
		var a = void 0;
		wx.getStorageSync("province_info") && (a = JSON.parse(wx.getStorageSync("province_info")).province_id), 
		a ? (this.province = a, this.get_location()) : this.get_location();
	},
	mounted: function() {
		window.addEventListener("scroll", this.handleScroll, {
			passive: false
		});
	}
});